package xuhaijia.lanou3g.autohome.forum;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

import java.util.ArrayList;

/**
 * Created by dllo on 16/8/15.
 */
public class PrimaryAdapter extends FragmentPagerAdapter{
    private ArrayList<String> tbArrayLists;
    private ArrayList<Fragment> fragments;
    public PrimaryAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setFragments(ArrayList<Fragment> fragments) {
        this.fragments = fragments;
        notifyDataSetChanged();
    }

    public void setTbArrayLists(ArrayList<String> tbArrayLists) {
        this.tbArrayLists = tbArrayLists;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return tbArrayLists != null ? tbArrayLists.size() : 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tbArrayLists.get(position);
    }
}
